home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
vbdatabs
/
htmldrv.h
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-30
|
13KB
|
284 lines
// ------------------------------- //
// -------- Start of File -------- //
// ------------------------------- //
// ----------------------------------------------------------- //
// C++ Header File Name: htmldrv.h
// Compiler Used: MSVC40, DJGPP 2.7.2.1, GCC 2.7.2.1, HP CPP 10.24
// Produced By: Doug Gaer
// File Creation Date: 03/09/1999
// Date Last Modified: 03/31/1999
// Copyright (c) 1997 Douglas M. Gaer
// ----------------------------------------------------------- //
// ---------- Include File Description and Details ---------- //
// ----------------------------------------------------------- //
/*
The VBD C++ classes are copyright (c) 1997, by Douglas M. Gaer.
All those who put this code or its derivatives in a commercial
product MUST mention this copyright in their documentation for
users of the products in which this code or its derivative
classes are used. Otherwise, you have the freedom to redistribute
verbatim copies of this source code, adapt it to your specific
needs, or improve the code and release your improvements to the
public provided that the modified files carry prominent notices
stating that you changed the files and the date of any change.
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
CORRECTION.
The HyperTextDrv and HyperText class is used to create HTML
documents. The HyperTextDrv class is a base class that uses
the C++ ostream library to write HTML tags and text to a
specified stream. The HyperText class is used to write
HTML document templates to a specified stream,
*/
// ----------------------------------------------------------- //
#ifndef __HTMLDRV_HPP__
#define __HTMLDRV_HPP__
#include <fstream.h>
// Constants
const int DefaultPrecision = 2; // Default precision for floating points
// Define some common HTML colors
const int NumHTMLColors = 16;
enum htmCOLORS {
htmBLACK = 0x000000,
htmDARKBLUE = 0x000080,
htmBLUE = 0x0000ff,
htmGREEN = 0x008000,
htmTEAL = 0x008080,
htmBRIGHTGREEN = 0x00ff00,
htmTURQUOISE = 0x00ffff,
htmDARKRED = 0x800000,
htmVIOLET = 0x800080,
htmDARKYELLOW = 0x808000,
htmDARKGRAY = 0x808080,
htmGRAY = 0xC0C0C0,
htmRED = 0xff0000,
htmPINK = 0xff00ff,
htmYELLOW = 0xffff00,
htmWHITE = 0xffffff
};
// Define some common HTML fonts
const int NumHTMLFonts = 4;
enum htmFONTS {
htmARIAL, // Arial
htmARIALBLACK, // Arial Black
htmARIALNARROW, // Arial Narrow
htmCOURIER // Courier New
};
// Functions used to print characters with special meaning
inline ostream& lt(ostream &s) { return s << "<"; } // Less than sign
inline ostream& gt(ostream &s) { return s << ">"; } // Greater than sign
inline ostream& amp(ostream &s) { return s << "&"; } // Ampersand
inline ostream& quot(ostream &s) { return s << "\""; } // Double quote sign
// Functions used to print special characters
inline ostream& nbsp(ostream &s) { return s << " "; } //Non-brk space
inline ostream& hyphen(ostream &s) { return s << ""; } // Soft-hyphen
inline ostream& copyright(ostream &s) { return s << "©"; }
inline ostream& registered(ostream &s) { return s << "®"; }
// Functions used to create HMTL tags
inline ostream& stag(ostream &s) { return s << "<"; } // Start tag
inline ostream& etag(ostream &s) { return s << "</"; } // End tag
inline ostream& ctag(ostream &s) { return s << ">"; } // Close tag
// HTML document formatting functions
inline ostream& anchor(ostream &s) { return s << "<A>"; }
inline ostream& eanchor(ostream &s) { return s << "</A>"; }
inline ostream& comment(ostream &s) { return s << "<!-- "; }
inline ostream& ecomment(ostream &s) { return s << " -->"; }
inline ostream& body(ostream &s) { return s << "<BODY>"; }
inline ostream& ebody(ostream &s) { return s << "</BODY>"; }
inline ostream& br(ostream &s) { return s << "<BR>"; }
inline ostream& head(ostream &s) { return s << "<HEAD>"; }
inline ostream& ehead(ostream &s) { return s << "</HEAD>"; }
inline ostream& html(ostream &s) { return s << "<HTML>"; }
inline ostream& ehtml(ostream &s) { return s << "</HTML>"; }
inline ostream& hr(ostream &s) { return s << "<HR>"; }
inline ostream& par(ostream &s) { return s << "<P>"; }
inline ostream& epar(ostream &s) { return s << "</P>"; }
inline ostream& pre(ostream &s) { return s << "<PRE>"; }
inline ostream& epre(ostream &s) { return s << "</PRE>"; }
inline ostream& title(ostream &s) { return s << "<TITLE>"; }
inline ostream& etitle(ostream &s) { return s << "</TITLE>"; }
// HTML font formatting functions
inline ostream& bold(ostream &s) { return s << "<B>"; }
inline ostream& ebold(ostream &s) { return s << "</B>"; }
inline ostream& center(ostream &s) { return s << "<CENTER>"; }
inline ostream& ecenter(ostream &s) { return s << "</CENTER>"; }
inline ostream& font(ostream &s) { return s << "<FONT>"; }
inline ostream& efont(ostream &s) { return s << "</FONT>"; }
inline ostream& h1(ostream &s) { return s << "<H1>"; }
inline ostream& eh1(ostream &s) { return s << "</H1>"; }
inline ostream& h2(ostream &s) { return s << "<H2>"; }
inline ostream& eh2(ostream &s) { return s << "</H2>"; }
inline ostream& h3(ostream &s) { return s << "<H3>"; }
inline ostream& eh3(ostream &s) { return s << "</H3>"; }
inline ostream& italic(ostream &s) { return s << "<I>"; }
inline ostream& eitalic(ostream &s) { return s << "</I>"; }
inline ostream& underline(ostream &s) { return s << "<U>"; }
inline ostream& eunderline(ostream &s) { return s << "</U>"; }
// HTML table functions
inline ostream& table(ostream &s) { return s << "<TABLE>"; }
inline ostream& otable(ostream &s) { return s << "<TABLE "; }
inline ostream& etable(ostream &s) { return s << "</TABLE>"; }
inline ostream& tr(ostream &s) { return s << "<TR>"; }
inline ostream& etr(ostream &s) { return s << "</TR>"; }
inline ostream& th(ostream &s) { return s << "<TH>"; }
inline ostream& eth(ostream &s) { return s << "</TH>"; }
inline ostream& td(ostream &s) { return s << "<TD>"; }
inline ostream& etd(ostream &s) { return s << "</TD>"; }
// HTML driver base class
class HyperTextDrv
{
public:
HyperTextDrv(ostream &s);
virtual ~HyperTextDrv();
protected: // Filtered output functions used to write HTML text
virtual void WriteString(const char *s);
virtual void WriteChar(const unsigned char c) const;
public: // Functions used to write built-in data types
void Write(const char c) const;
void Write(const unsigned char c) const;
void Write(char c);
void Write(unsigned char c);
void Write(const char *s);
void Write(char *s);
void Write(const unsigned char *s);
void Write(unsigned char *s);
void Write(const long val) const;
void Write(long val);
void Write(const unsigned long val) const;
void Write(unsigned long val);
void Write(const int val) const;
void Write(int val);
void Write(const unsigned int val) const;
void Write(unsigned int val);
void Write(double val);
void Write(const double val) const;
void Write(float val);
void Write(const float val) const;
public:
void precision(int p) { dec_precision = p; } // Floating precision
void eat_space() { non_breaking_sp = 1; } // Use non-breaking spaces
void put_space() { non_breaking_sp = 0; } // Use breaking spaces
public: // Overloaded operators
ostream &operator<<(ostream & (*_f)(ostream&));
HyperTextDrv &operator<<(char *s);
HyperTextDrv &operator<<(const char *s);
HyperTextDrv &operator<<(unsigned char *s);
HyperTextDrv &operator<<(const unsigned char *s);
HyperTextDrv &operator<<(char c);
const HyperTextDrv &operator<<(const char c) const;
HyperTextDrv &operator<<(unsigned char c);
const HyperTextDrv &operator<<(const unsigned char c) const;
HyperTextDrv &operator<<